/*************************************************************************
	> File Name: P2032.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-01-03 11:21:18
 ************************************************************************/
#include <iostream>
#include <deque>
using namespace std;

#define MAX_N 2000000
int arr[MAX_N + 5];

int main() {
    int n, k;
    deque<int> q;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    for (int i = 0; i < n; i++) {
        while (!q.empty() && arr[i] >= arr[q.back()]) q.pop_back();
        q.push_back(i);
        if (i >= k - 1) {
            cout << arr[q.front()] << endl;
            if (i - q.front() + 1 == k) q.pop_front();
        }
    }
    return 0;
}
